package com.hancheng.ordercloud.framework.kafka;

import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class OrderKafkaConsumer {

    @KafkaListener(topics = "goods-events")
    public void listenGoodsEvent(String message, Acknowledgment ack) {
        try {
            log.info("我接收到商品模块发送的消息: {}", message);
            //手动提交
            ack.acknowledge();
        }catch (Exception e) {
            log.info("消息处理失败：{}" + e.getMessage());
            // 不 ack，消息将再次消费（可实现重试机制）
        }

    }
}
